<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
{include file='top.tpl'}
{literal}
<style>
.box-body{min-height:350px;}
.table-toolbar .columns-right{position:relative;}
.table-toolbar .dropdown-menu{right:0;left:auto;max-height:340px;overflow:auto;}
.table-toolbar .dropdown-menu li{padding:5px 15px;}
.table-toolbar .dropdown-menu li p{margin:0;}
.img-thumbnail{width:50px;height:50px;}
.nav-tabs-custom{box-shadow:none;margin:10px 10px 0px 10px;}

.slct{display:inline-block; width:auto;}
</style>
{/literal}
</head>
<body class="skin-blue">
<div class="wrapper">
	{include file='bread_crumbs.tpl'}
	<!--引入面包屑-->
	<section class="base-setting-wrap">
		<div class="row">
			<div class="col-md-12">
				<div class="box">
					
					<div class="nav-tabs-custom">
						<ul class="nav nav-tabs">
					      <li class="active"><a href="/purchase/sample-cloth/sample">样衣需求列表</a></li>
					      <li><a href="/purchase/sample-cloth/fb">样衣推广跟踪表</a></li>					      
					    </ul>
				    </div>
	                <div class="box-header with-border clearfix">
	                		                	
	                	<div class="box-form pull-right form-group-sm">
	                		<p class="pull-right">
	                			<a href="javascript:;" class="btn btn-success btn-sm" id="js_toggleSearchBox"><i class="fa fa-search"></i><span class="pl5">搜索选项</span></a>
	                		</p>
	                		<a class="btn btn-primary btn-sm pull-right" href="/purchase/sample-cloth/add">添加样衣需求</a>
	                	</div>
	                	<div class="clearfix"></div>
						<div class="search-box" id="js_searchBox">
							<form method="get" action class="form-inline">
								<div class="form-group-sm">	
									<p>
										<label class="control-label ml10">搜索关键字类别：</label>
										<select name='key' class="form-control">
			                				<option value="sku" {if $filter.key == 'sku'}selected=selected{/if}>产品编码</option>	
			                				<option value="supplier_sn" {if $filter.key == 'supplier_sn'}selected=selected{/if}>供应商编码</option>
			                				<option value="supplier_name" {if $filter.key == 'supplier_name'}selected=selected{/if}>供应商名称</option>		
		                					<option value="purchaser" {if $filter.key == 'purchaser'}selected=selected{/if}>采购员</option>
		                					<option value="add_user" {if $filter.key == 'add_user'}selected=selected{/if}>提交人</option>
		                				</select>
										<input type="text" class="form-control" name="value" value="{$filter.value}">																		
										<label class="control-label ml10">货源状态：</label>
										<select name="good_status" class="form-control">
											<option value=''>请选择</option>
											{foreach $good_status as $k => $t}
			                				<option value="{$k}" {if $filter.good_status==$k}selected=selected{/if}>{$t}</option>
			                				{/foreach}										
										</select>
										
										<label class="control-label">提交时间：</label>
										<input type="text" class="form-control date_start" name="start" value="{$filter.start}">到
										<input type="text" class="form-control date_end" name="end" value="{$filter.end}">															
									</p>						
									
									<p class="no-margin">
										<label class="control-label">同步状态：</label>
										<select name="sync_status" class="form-control">
											<option value="">请选择</option>
											{foreach $sync_status as $k => $t}
			                				<option value="{$k}" {if $filter.sync_status != '' && $filter.sync_status eq $k}selected=selected{/if}>{$t}</option>
			                				{/foreach}							
										</select>	
										
										<label class="control-label ml10">需求状态：</label>
										<select name='privide_status' class="form-control">
			                				<option value="">请选择</option>
			                				{foreach $privide_status as $k => $t}
			                				<option value="{$k}" {if $filter.privide_status !='' && $filter.privide_status eq $k}selected=selected{/if}>{$t}</option>
			                				{/foreach}
		                				</select>
		                				
		                				<label class="control-label ml10">是否已推广：</label>
										<select name="is_extended" class="form-control">
			                				<option value="">所有</option>
			                				<option value="0" {if $filter.is_extended eq '0'}selected=selected{/if}>未推广</option>
			                				<option value="1" {if $filter.is_extended eq '1'}selected=selected{/if}>已推广</option>			                		
		                				</select>
		                				
		                				<label class="control-label ml10">样衣类型：</label>
										<select name="sample_type" class="form-control">
			                				<option value="">全部</option>
			                				{foreach $sample_type as $k => $t}
			                				<option value="{$k}" {if $filter.sample_type==$k}selected=selected{/if}>{$t}</option>
			                				{/foreach}			                		
		                				</select>
										
										<button type="submit" class="btn btn-primary btn-sm">立即搜索</button>
									</p>
								</div>
							</form>
						</div>
	                </div>
	                <!-- /.box-header -->

	                <div class="box-body">
						

	                  <table class="table table-bordered table-striped table-hover" id="js_productTable">
	                  	<thead>
	                    <tr>
	                      <th width="65"><input type="checkbox" name="checkall"></th>
	                      <th data-field="operate" data-checked="true">操作</th>
	                      <th data-field="pcode" data-checked="true">产品编码</th>                      
	                      <th data-field="pcode" data-checked="true">产品图片</th>
	                      <th data-field="title" data-checked="true" width="280">参考成本</th>
	                      <th data-field="product_from" data-checked="true">需求数量</th>
	                      <!-- <th data-field="product_image" data-checked="true">回货数量</th> -->
	                      <th data-field="product_category" data-checked="true">供应商编码</th>
	                      <th data-field="develop_category" data-checked="true">采购员</th>
	                      <th data-field="develop_website" data-checked="true">货源状态</th>
	                      <th data-field="apply_mark" data-checked="true">产品状态</th>
	                      <!-- <th data-field="apply_time" data-checked="true">采购类型</th> -->
	                      <th data-field="apply_user" data-checked="true">样衣类型</th>
	                      <th data-field="develop_time" data-checked="true">存放仓库</th>
	                      <th data-field="develop_user" data-checked="true">备注</th>
	                      <th data-field="develop_mark" data-checked="true">提交人</th>
	                      <th data-field="develop_status" data-checked="true">提交时间</th>
	                      <th data-field="promote_time" data-checked="false">同步状态</th>
	                      <th data-field="promote_user" data-checked="false">需求状态</th>
	                      <th data-field="promote_mark" data-checked="false">需求状态信息</th>
	                      <th data-field="promote_status" data-checked="false">是否已推广</th>
	                    </tr>
	                    </thead>	                    
	                    {foreach $list as $item}
	                    <tr>
							<td>
								<input type="checkbox" name="checkitem" value="{$item.id}">
							</td>	
							<td>
								{if $item.is_extended eq 0}
	                    		<a href="javascript:void(0);" class="btn btn-primary btn-sm" onclick="do_extend({$item.id},'{$item.sku}')">推广</a>
	                    		{/if}
	                    	</td>                    	
							<td>{$item.sku}</td>
							<td><img src="{$pre_img}{$item.img}" alt=""></td>
							<td>{$item.price}</td>
							<td>{$item.num}</td>
							<!-- <td>{$item.provide_qty}</td> -->
							<td>{$item.supplier_sn}</td>
							<td>{$item.purchaser}</td>
							<td>{$good_status[$item.goods_status]}</td>
							<td>{$good_status[$item.goods_status]}</td>
							<!-- <td>{if $item.purchase_type eq '1'}普通采购{else}批量采购{/if}</td> -->
							<td>{$sample_type[$item.sample_type]}</td>
							<td>样衣仓</td>
							<td>{$item.remark}</td>
							<td>{$item.add_user}</td>
							<td>{$item.add_time}</td>
							<td>{$sync_status[$item.sync_status]}</td>
							<td>{$privide_status[$item.provide_status]}</td>
							<td>{$item.provide_info}</td>
							<td>{if $item.is_extended}已推广{else}未推广{/if}</td>
						</tr>
	                    {/foreach}					                 
	              	</table>
	              	<div class="form-group-sm mt20">
	              		<button type="submit" class="btn btn-primary btn-sm" id="entend_betch">批量推广</button>
	              	</div>
	                </div>
	                <!-- .box-body -->
	                <div class="box-footer text-center clearfix">
                		{$page_link}
	                </div>
	              </div>
			</div>
		</div>
	</section>
</div>

{include file='foot.tpl'}
<script>
{literal}
//全选反选
$.fn.check({checkall_name: "checkall", checkbox_name:"checkitem"});

$('.date_start').datetimepicker({
    format: "yyyy-mm-dd",
    minView:2,
    autoclose: true,
    todayHighlight: false
}).on('changeDate', function(ev){
    $(".date_end").val("").datetimepicker('setStartDate',$(this).val());
});
$('.date_end').datetimepicker({
    format: "yyyy-mm-dd",
    minView:2,
    autoclose: true,
    todayHighlight: false
});

function do_extend(id, sku) {
	layer.confirm("确定要推广编码为【 <span style='color:red;'>"+sku+" </span>】的产品吗？", function(){
		$.post('/purchase/sample-cloth/extend-sample', {id:id}, function(res) {
			if(res.opr == '1'){
                layer.alert(res.content,8);
                location.reload();
            }else if(res.opr == '0'){
                layer.alert(res.content,8);
            }else {
            	layer.alert(res.message);
            }
		}, 'json');
	});
}
$("#entend_betch").bind("click", function() {
	var ids = [];
	$("input[name=checkitem]").each(function(index,node){
		if ($(node).prop('checked')) {
			ids.push($(node).val());
		};
	})
	if (ids.length < 1) {
		layer.alert("请选择要推广的产品");
		return false;
	};

	layer.confirm("确定要推广这些产品吗？", function(){
		$.post('/purchase/sample-cloth/extend-sample', {id:ids.join()}, function(res) {
			if(res.opr == '1'){
                layer.alert(res.content,8);
                location.reload();
            }else if(res.opr == '0'){
                layer.alert(res.content,8);
            } else {
            	layer.alert(res.message);
            }
		}, 'json');
	});
})
{/literal}
</script>
</body>
</html>